package com.prd.common.converter;


import com.prd.common.baseMapper.ApiResult;
import com.prd.common.constant.ResultMessageConstants;
import com.prd.common.exception.NullSidException;
import com.prd.common.exception.UnLoginException;

/**
 * 异常转换器
 * 
 * @author xqf
 *
 */
public class ExceptionConverter {
	/**
	 * 将异常信息装换成提示信息
	 * 
	 * @param reslut
	 * @param e
	 */
	public static void converter(ApiResult reslut, Exception e) {
//		if (e instanceof com.alibaba.dubbo.rpc.RpcException) {
//			reslut.setMessage(ResultMessageConstants.B00002.name());
//		} else 
		if (e instanceof UnLoginException) {
			reslut.setMessage(ResultMessageConstants.B00003.name());
		} else if (e instanceof NullSidException) {
			reslut.setMessage(ResultMessageConstants.B00004.name());
		} else if (e.getStackTrace().equals("")) {
			reslut.setMessage(ResultMessageConstants.B00004.name());
		} else {
			reslut.setMessage(ResultMessageConstants.B00001.name());
		}
	}
}
